#include <stdio.h>
#include <math.h>

int search( int n );

int main()
{
	int number;
	
	scanf("%d",&number);
	printf("count=%d\n",search(number));
	
	return 0;
}


/* 你的代码将被嵌在这里 */
int search( int n ){
	int num = 0;
	int a[3];
	for(int i=11;i*i <= n;i++){
		a[0] = i*i % 10;
		a[1] = (i*i / 10) % 10;
		a[2] = i*i / 100;
		if(a[0] == a[1] || a[0] == a[2] || a[1] == a[2]){
			num ++;
		}
		
	}
	return num;
}
